package com.hhh.demo2;

/**
 * @author zzzzz
 * @create 08-23
 */
public class Demo1 {

    public static void demo1(int n){
        for(int i = 1;i<=n;i++){
            for(int k = n-i;k>0;k--){
                System.out.print(" ");
            }
            for(int j = 1;j<=2*i-1;j++){
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public static void demo2(int n){
        for(int i = 1;i<=n;i++){
            for (int k = n - i; k > 0; k--) {
                System.out.print(" ");
            }
            if(i == 1 || i == n){
                for (int j = 1; j <= 2 * i - 1; j++) {
                    System.out.print("*");
                }
            }else {
                for (int j = 1; j <= 2 * i - 1; j++) {
                    if(j == 1 || j == (2*i-1)){
                        System.out.print("*");
                    }else{
                        System.out.print(" ");
                    }
                }
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        demo1(10);
        demo2(6);
    }
}
